package com.headStorm.socket.tcp;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author zhangqq
 * @create 2020-12-29 11:54
 **/
public class TcpServer {
    public static void main(String[] args) throws IOException {
        System.out.println("--------server----------");
        //1.定义服务端
        ServerSocket server = new ServerSocket(7788);
        //2.阻塞式监听   Socket accept()
        Socket client = server.accept();
        //3.io操作
        //输入流
        DataInputStream is = new DataInputStream(client.getInputStream());
        System.out.println(is.readUTF());
        //4.关闭
        is.close();
    }
}
